package com.innoking.docsys.doc.service.impl;

import com.innoking.docsys.doc.dao.cluster.ClusterUpmsArchivesTypesMapper;
import com.innoking.docsys.doc.dao.cluster.ClusterUpmsFondsManageMapper;
import com.innoking.docsys.doc.dto.UpmsArchivesTypes;
import com.innoking.docsys.doc.dto.UpmsFondsManage;
import com.innoking.docsys.doc.example.UpmsArchivesTypesExample;
import com.innoking.docsys.doc.example.UpmsFondsManageExample;
import com.innoking.docsys.doc.module.UpmsFondsManageVO;
import com.innoking.docsys.doc.service.GetClassByFoodsService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName getClassByFoodsServiceImpl
 * @Description 获取全宗分类
 * @Author wr
 * @Date 2019/9/9 000915:48
 */
@Service
public class GetClassByFoodsServiceImpl implements GetClassByFoodsService {
    Logger logger= LoggerFactory.getLogger(GetClassByFoodsServiceImpl.class);

    @Autowired
    private ClusterUpmsArchivesTypesMapper clusterUpmsArchivesTypesMapper;

    @Autowired
    private ClusterUpmsFondsManageMapper clusterUpmsFondsManageMapper;

    @Override
    public List<UpmsArchivesTypes> getClassByFoodsId(String id) {
        logger.info("***获取原文Service入参：id="+id);
        if(StringUtils.isBlank(id)){ return null; }
        UpmsArchivesTypesExample upmsArchivesTypesExample = new UpmsArchivesTypesExample();
        UpmsArchivesTypesExample.Criteria criteria = upmsArchivesTypesExample.createCriteria();
        criteria.andFondsIdEqualTo(Integer.valueOf(id));
        upmsArchivesTypesExample.setOrderByClause("SORT_NUM ASC");
        List<UpmsArchivesTypes> upmsArchivesTypes = clusterUpmsArchivesTypesMapper.selectByExample(upmsArchivesTypesExample);
        if(upmsArchivesTypes.size() != 0){
            return upmsArchivesTypes;
        }else {
            return null;
        }
    }

    @Override
    public List<UpmsFondsManage> getFondsAll() {
        UpmsFondsManageExample upmsFondsManageExample = new UpmsFondsManageExample();
        List<UpmsFondsManage> upmsFondsManages = clusterUpmsFondsManageMapper.selectByExample(upmsFondsManageExample);
        return upmsFondsManages;
    }
}
